<template>
  <div>
    <van-nav-bar
     
      title="标题"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
     
    />

    <van-card
    @click="change(item.id)"
      :price="item.price"
      desc="描述信息xxx"
      :title="item.goodsname"
      :thumb="$host+item.img"
      v-for="(item,index) in menus"
      :key="index"
    >
     <template #footer>
            <van-button width="20px" @click.stop="join(item.id)" icon="shopping-cart-o" size="small" type="primary" />
          </template>
    </van-card>
  </div>
</template>

<script>
import { getlei,joini} from "../radio/index";
export default {
    created(){
        console.log(this.$route.params.id);
    this.ruleForm.uid=JSON.parse(localStorage.getItem("userInfo2")).uid

    this.get()
    },
  data() {
    return {
        menus:[],
         ruleForm:{
        uid:"",
        goodsid:"",
        num:1
      },
    };
  },
  methods: {
    async joingouwu(){
    let res=await joini(this.ruleForm)
    if(res.code==200){
      this.$toast('添加成功');
    }
    },
    join(id){
      this.ruleForm.goodsid=id
      this.joingouwu()
    },
     change(id){
      this.$router.push("/xiang/"+id)
    },
    async get() {
      let res = await getlei({ params: { fid:this.$route.params.id } });
      console.log(res.list.list);
      this.menus=res.list.list
    },
    onClickLeft() {
      this.$router.back();
    },
  },
};
</script>

<style>
</style>